package engine.network.hostSide.abstractClasses;

import graphicUserInterface.elements.PositionListener;

import java.awt.Point;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public abstract class PositionHandler {
	/* *********************************************************
	 * Attributes
	 * ********************************************************* */
	protected List<PositionListener> _listeners;
	
	/* *********************************************************
	 * Constructor(s)
	 * ********************************************************* */
	public PositionHandler(){
		_listeners = new LinkedList<PositionListener>();
	}
	
	/* *********************************************************
	 * Instance Methods
	 * ********************************************************* */
	public void attach(PositionListener newListener){
		_listeners.add(newListener);
	}
	
	public void detach(PositionListener newListener){
		_listeners.remove(newListener);
	}
	
	public void notify(Point p){
		Iterator<PositionListener> ite = _listeners.iterator();
		while(ite.hasNext()){
			ite.next().update(p);
		}
	}
}
